﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
namespace _5._18
{
    public static   class DBHelper
    {
        static string zx = "Data Source=(local);Initial Catalog=GoodsDB;Integrated Security=True";
        public static DataTable read(string sql)
        {
            SqlConnection conn = new SqlConnection(zx);
            conn.Open();
            SqlCommand jk = new SqlCommand(sql,conn);
            SqlDataAdapter nm = new SqlDataAdapter(jk);
            DataTable table = new DataTable();
            nm.Fill(table);
            conn.Close();
            return table;
        }
        public static int write(string sql)
        {
            SqlConnection conn = new SqlConnection(zx);
            conn.Open();
            SqlCommand jk = new SqlCommand(sql, conn);
            int rs = jk.ExecuteNonQuery();
            return rs;
        }
    }
}
